<?php 
require_once("../includes/config.inc.php");
if($_POST)
	{
		@extract($_POST);
		$sql = " select userName,password,email from tbl_admin  where  userName = '$userName' ";
		$result= executeQuery($sql);
		
		if($record = mysql_fetch_array($result))
		 {
				ob_start();
				include("../mailTemplate.php");
				$mailTemplate = ob_get_contents();
				ob_clean();
				$sqlSC = " select * from tbl_mail where mailId = '2' ";
				$resSC = executeQuery($sqlSC);
				if($rowSC = mysql_fetch_array($resSC))
				{
					$subject= $rowSC['subject'];
					$content= $rowSC['content'];
					$mailBody=$content."<br>";
					
					$mailBody = str_replace("<userName>",$record['userName'],$mailBody);
					$mailBody = str_replace("<password>",$record['password'],$mailBody);
					$mailBody = str_replace("<email>",$record['email'],$mailBody);
					$mailBody = nl2br($mailBody);
					$mailBody = str_replace("<MAIL_CONTENT>","$mailBody",$mailTemplate);
										//echo $mailBody; exit;
					send_mail($record['email'],$subject,$mailBody,$rowSC['email'],$rowSC['fromText'],$html=true);
					$msg = " You can check your Email ID for UserName and Password.";
					header("location: index.php?msg=$msg");
					exit();
			     }
		      }
		    else
			 {
				$message = 'Please check your user detail and try again.';
			 }	
	}
?>